<?php
    class sscls_SearchModel extends sscls_Model
    {   

        function __construct()
        {
            parent::__construct();
        }
      
	   function searchArticle($keyword='')
		{
			$query="select * from article WHERE (title LIKE '%".$keyword."%' or content LIKE '%".$keyword."%') and published=1";
			return $this->_getList($query,10,$this->getArticleTotal($keyword),'searchproduct');
		}
		function getArticleTotal($keyword)
		{	
			$query="select count(id) from article WHERE (title LIKE '%".$keyword."%' or content LIKE '%".$keyword."%') and published=1";
			return $this->_db->loadResult($query);
		}
	  
		function searchProduct($keyword)
		{
			$post=sscls_Request::get('post');	
			$query="select * from products WHERE productname LIKE '%".$keyword."%' and published=1";
			return $this->_getList($query,10,$this->getProductTotal($keyword),'searcharticle');
		}
		function getProductTotal($keyword)
		{
			$post=sscls_Request::get('post');	
			$query="select count(id) from products WHERE productname LIKE '%".$keyword."%' and published=1";
			return $this->_db->loadResult($query);
		}
		function getImage($productid)
		{
			return $this->_db->loadObjectList('select * from product_images where productid='.(int)$productid.' limit 0,1');
		}
	 
	   
	  
    }
?>
